import { http } from '@/api/Request'
import type { LoginData, UserInfo } from '@/api/types/user'

/**
 * 用户登录
 * @param data 登录表单数据
 */
export const login = (data: LoginData) => {
  return http.post<{ token: string }>('/auth/login', data)
}

/**
 * 用户登出
 */
export const logout = () => {
  return http.post('/auth/logout')
}

/**
 * 获取用户信息
 */
export const getUserInfo = () => {
  return http.get<{
    userInfo: UserInfo
    roles: string[]
    permissions: string[]
  }>('/user/info')
}